import collections
import itertools
import math

A, B = map(int, input().split())
M = A + B
# 计算层数
n1, n2 = (-1 + math.sqrt(8 * M + 1)) / 2, (-1 - math.sqrt(8 * M + 1)) / 2
result = 0


def solven():
    if n1 * n1 + n1 == 2 * M:
        n = n1
    elif n2 * n2 + n2 == 2 * M:
        n = n2
    else:
        return 0
    return int(n)


n = solven()
# 用0代表a 1代表b
total_array = [0] * A + [1] * B
permutation = set(itertools.permutations(total_array, n))


def isValid(per):
    c_a, c_b = 0, 0
    while per:
        nums = collections.Counter(per)
        c_a += nums[0]
        c_b += nums[1]
        if c_a > A or c_b > B:
            return False
        if len(p) > 1:
            prev_floor = [p[i] ^ p[i + 1] for i in range(len(per) - 1)]
            per = prev_floor
        else:
            break
    return True


for p in permutation:
    if isValid(p):
        result += 1
print(result)
